package sdp;

public class PcServer {
	private ImageViewer  viewer = null;
	private World        world  = null;
	private Control      ctrl   = null;
	private ControlPanel panel  = null;
	private Timer        timer  = null;
	private boolean      running = false;
	
	public PcServer() {
		World.Settings settings = new World.Settings();
		settings.ballState       = new BallState( new Vector2(0.0,0.0), 0.4);
		settings.motorCount      = 3;
		settings.playerState     = new RobotState( RobotState.Team.YELLOW, new Vector2(0.5,0.5), new Vector2(0.3,0.3), 0.0 );
		settings.opponentState   = new RobotState( RobotState.Team.BLUE,   new Vector2(0.5,0.5), new Vector2(0.3,0.3), 0.0 );
		settings.pitchBottomLeft = new Vector2(0.0,0.0);
		settings.pitchTopRight   = new Vector2(1.0,1.0);
		
		timer  = new Timer();
		panel  = new ControlPanel();
		viewer = new ImageViewer();
		world  = new NxtWorld( settings, viewer, panel );
		ctrl   = new Control( world, panel, timer );
	}
	
	public void run() {
		running = true;
		int step = 0;
		while( running ) {
			step++;
			timer.update();
			ctrl.update();
			world.update();
			if( step == 5 ) {
				ctrl.setGoalRotation( Math.PI );
			}
		}
	}
	
	public static void main( String args[] ) {
		PcServer server = new PcServer();
		server.run();
	}
}
